﻿<cfsilent>
	<cfscript>
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		targetWeek = event.getArg("W");
		
		passArgs = structNew();
		structInsert( passArgs, "TSK", taskId );
		structInsert( passArgs, "TT", taskType );
		structInsert( passArgs, "TID", termId );
		structInsert( passArgs, "W", targetWeek );
		
		switch(taskType){
			case "C":
				sql = "SELECT 
							t_course.course_name, 
							a.task_week, 
							t_teacher.tch_name 
						FROM 
							t_common_task a 
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;

			case "P":
				sql = "SELECT 
							t_course.course_name, 
							a.task_week, 
							t_teacher.tch_name 
						FROM 
							t_task a 
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;
			
			case "R":
				sql = "SELECT 
							t_course.course_name, 
							a.task_week, 
							t_teacher.tch_name 
						FROM 
							t_reopen_task a 
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;
			
			case "T":
				sql = "SELECT 
							t_course.course_name, 
							a.task_week, 
							t_teacher.tch_name 
						FROM 
							t_sport_task a 
							INNER JOIN t_course ON t_course.cid = a.cid 
							INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
						WHERE 
							a.tsk_id = :taskId ";
				break;
		}
		
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		rs_task = queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "教学任务安排 - 停课向导 - " & rs_task.course_name );
		
		sql = "SELECT 
					t_task_timetable.tasktime 
				FROM 
					t_task_timetable 
					INNER JOIN t_task_arrange ON t_task_arrange.task_id = t_task_timetable.task_id 
				WHERE 
					t_task_arrange.task_id = :taskId 
					AND 
					SUBSTR(t_task_timetable.widx, " &targetWeek& ", 1) = '1' 
					AND 
					t_task_arrange.term_id = :termId ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		rs_lecutre = queryObj.execute( sql=sql ).getResult();
	
		sql = "SELECT 
					tasktime, taskclsroom 
				FROM 
				   t_clsroom_forcourse 
				   INNER JOIN t_clsroom_timetable ON t_clsroom_timetable.crtime_id = t_clsroom_forcourse.crtime_id 
				WHERE 
					task_id = :taskId 
					AND 
					SUBSTR(t_clsroom_timetable.widx, " &targetWeek& ", 1) = '1' 
					AND 
					t_clsroom_timetable.term_id = :termId ";
					
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		rs_room = queryObj.execute( sql=sql ).getResult();
											
		timeTable = structNew();
		
		for ( i=1; i LTE rs_lecutre.recordCount; i++){
			tt = listToArray(rs_lecutre["tasktime"][i], "-@");
			structInsert( timeTable, "LEC-T" & tt[1] & tt[2] , tt[3] );
		}
		for ( j=1; j LTE rs_room.recordCount; j++){	
			tt = listToArray(rs_room["tasktime"][j], "-@");
			structInsert( timeTable, "LEC-R" & tt[1] & tt[2] , rs_room["taskclsroom"][j] );
		}
		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('taskTempChange')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">临时性调停课</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>临时停课向导 <cfoutput>#rs_task.course_name#</cfoutput>-<cfoutput>#rs_task.tch_name#</cfoutput> 
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<table class="UICourseTable">
					<thead>
						<tr>
							<td colspan="2" width="2%"></td>
							<td width="14%">星期一</td>
							<td width="14%">星期二</td>
							<td width="14%">星期三</td>
							<td width="14%">星期四</td>
							<td width="14%">星期五</td>
							<td width="14%">星期六</td>
							<td width="14%">星期天</td>
						</tr>
					</thead>
					<tbody>
						<cfloop from="1" to="6" index="lec">
							<tr>
								<cfswitch expression="#lec#">
									<cfcase value="1">
									<td rowspan="2"><cfoutput>#mathAdvice.convertLectureIdxToDayPart(lec)#</cfoutput></td>
									</cfcase>
									<cfcase value="3">
									<td rowspan="2"><cfoutput>#mathAdvice.convertLectureIdxToDayPart(lec)#</cfoutput></td>
									</cfcase>
									<cfcase value="5">
									<td rowspan="2"><cfoutput>#mathAdvice.convertLectureIdxToDayPart(lec)#</cfoutput></td>
									</cfcase>
								</cfswitch>
								<td><cfoutput>#mathAdvice.convertLectureIdxToChinese(lec)#</cfoutput></td>
								<cfloop from="1" to="7" index="wkday">
									<td>
										<cfif structKeyExists(timeTable, "LEC-T" & wkday & lec)>
											
											<cfset structInsert( passArgs, "TSKTIME", wkday & "@" & lec & "-" & timeTable["LEC-T"&wkday&lec], true ) />
											
											<a href="<cfoutput>#buildURL('taskChangeWizardStopSign', passArgs)#</cfoutput>">
											<cfoutput>#rs_task.course_name#</cfoutput>
											<cfif structKeyExists(timeTable, "LEC-R" & wkday & lec)>
												<br/>
												<cfoutput>#timeTable["LEC-R"&wkday&lec]#</cfoutput>
											</cfif>
											<br/>
											<cfoutput>#rs_task.task_week#</cfoutput>(<cfoutput>#timeTable["LEC-T"&wkday&lec]#</cfoutput>)
											</a>
										</cfif>
									</td>
								</cfloop>
							</tr>
						</cfloop>
					</tbody>
				</table>
			</div>
		</li>
	</ul>
</div>


